global class DeleteOldDataSchedule implements Schedulable {
    global void execute(SchedulableContext sc) {
        // 删除没有上班打卡时间的记录
        // 进入上下班打卡页面但是不打卡的话，会出现废数据
        List<ClockInOutHistory__c> delList1 = [select Id from ClockInOutHistory__c where ClockInTime__c = null];
        if (delList1.size() > 0) delete delList1;

        // 删除三个月以前的上下班打卡记录
        // Date today = Date.today();
        Date threeMonthBefore = Date.today().addMonths(-3);
        List<ClockInOutHistory__c> delList2 = [select Id from ClockInOutHistory__c where CreatedDate <= :threeMonthBefore];
        if (delList2.size() > 0) delete delList2;
    }
}